### Description

Query the execution status of a job by Job Instance ID

### Request Parameters

#### Query Parameters

| Field                        | Type    | Required | Description                                                                                                                                               |
|------------------------------|---------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| bk_scope_type                | string  | Yes      | Resource scope type. Allowed values: biz - Business, biz_set - Business Set                                                                               |
| bk_scope_id                  | string  | Yes      | Resource scope ID, corresponding to bk_scope_type. Indicates Biz ID or Biz Set ID                                                                         |
| job_instance_id              | long    | Yes      | Job instance ID                                                                                                                                           |
| return_execute_object_result | boolean | No       | Whether to return task details for each execute object (host/container), corresponding to step_execute_object_result_list in the response. Default false. |

### Request Example

- GET

```json
/api/v4/get_job_instance_status?bk_scope_type=biz&bk_scope_id=1&job_instance_id=100&return_ip_result=true
```

### Response Examples

#### Failure

{% include '_generic_v4_error_resp.md.j2' %}

#### Success

```json
# http status=200
{
    "data": {
        "finished": true,
        "job_instance": {
            "job_instance_id": 100,
            "bk_scope_type": "biz",
            "bk_scope_id": "1",
            "name": "API Quick execution script1",
            "create_time": 1605064271000,
            "status": 4,
            "start_time": 1605064271000,
            "end_time": 1605064272000,
            "total_time": 1000
        },
        "step_instance_list": [
            {
                "status": 4,
                "total_time": 1000,
                "name": "API Quick execution script1",
                "step_instance_id": 75,
                "execute_count": 0,
                "create_time": 1605064271000,
                "end_time": 1605064272000,
                "type": 1,
                "start_time": 1605064271000,
                "step_execute_object_result_list": [
                    {
                        "execute_object": {
                            "type": 1,
                            "resource_id": "101",
                            "host": {
                                "bk_host_id": 101,
                                "ip": "127.0.0.1",
                                "bk_cloud_id": 0
                            }
                        },
                        "status": 9,
                        "tag": "",
                        "exit_code": 0,
                        "error_code": 0,
                        "start_time": 1605064271000,
                        "end_time": 1605064272000,
                        "total_time": 1000
                    }
                ]
            }
        ]
    }
}
```

### Response Schema

{% include '_generic_v4_response.md.j2' %}

#### data

| Field                | Type   | Non-null | Description                                                     |
|----------------------|--------|----------|-----------------------------------------------------------------|
| finished             | bool   | Yes      | Whether the job has finished                                    |
| job_instance         | object | Yes      | Basic job instance info. See job_instance                       |
| step_instance_list   | array  | Yes      | List of job steps. See step_instance                            |

#### job_instance

| Field           | Type   | Non-null | Description                                                                 |
|-----------------|--------|----------|-----------------------------------------------------------------------------|
| name            | string | Yes      | Job instance name                                                           |
| status          | int    | Yes      | Job status code. See run_status                                             |
| create_time     | long   | Yes      | Job creation time. Unix timestamp in milliseconds                           |
| start_time      | long   | No       | Job start time. Unix timestamp in milliseconds                              |
| end_time        | long   | No       | Job end time. Unix timestamp in milliseconds                                |
| total_time      | int    | No       | Total elapsed time in milliseconds                                          |
| bk_scope_type   | string | Yes      | Resource scope type. Allowed values: biz - Business, biz_set - Business Set |
| bk_scope_id     | string | Yes      | Resource scope ID, corresponding to bk_scope_type                           |
| job_instance_id | long   | Yes      | Job instance ID                                                             |

#### step_instance

| Field                           | Type   | Non-null | Description                                                                                                                                            |
|---------------------------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| step_instance_id                | long   | Yes      | Step instance ID                                                                                                                                       |
| type                            | int    | Yes      | Step type. 1 - Script; 2 - File; 3 - Manual confirm; 4 - SQL                                                                                           |
| name                            | string | Yes      | Step name                                                                                                                                              |
| status                          | int    | Yes      | Step status code. See run_status                                                                                                                       |
| create_time                     | long   | Yes      | Step creation time. Unix timestamp in milliseconds                                                                                                     |
| start_time                      | long   | Yes      | Step start time. Unix timestamp in milliseconds                                                                                                        |
| end_time                        | long   | Yes      | Step end time. Unix timestamp in milliseconds                                                                                                          |
| total_time                      | int    | Yes      | Total elapsed time in milliseconds                                                                                                                     |
| execute_count                   | int    | Yes      | Retry count                                                                                                                                            |
| step_execute_object_result_list | array  | No       | Task execution result for each execute object (host/container). Present only when return_execute_object_result is true. See step_execute_object_result |

#### step_execute_object_result

| Field          | Type   | Non-null | Description                                                                                 |
|----------------|--------|----------|---------------------------------------------------------------------------------------------|
| execute_object | object | Yes      | Execute object. See execute_object definition                                               |
| status         | int    | Yes      | Task status on the execute object. See target_object_status                                 |
| tag            | string | No       | User-defined result produced by template functions job_success/job_fail. Script step only   |
| exit_code      | int    | No       | Script exit code. Present for script steps                                                  |
| start_time     | long   | Yes      | Start time. Unix timestamp in milliseconds                                                  |
| end_time       | long   | Yes      | End time. Unix timestamp in milliseconds                                                    |
| total_time     | int    | Yes      | Total elapsed time in milliseconds                                                          |

#### execute_object

{% include '_generic_execute_object.md.j2' %}

#### run_status

{% include '_generic_task_status.md.j2' %}

#### target_object_status

{% include '_generic_target_object_status.md.j2' %}
